<?php
/**
 * Created by PhpStorm.
 * User: yu
 * Date: 2017/1/6
 * Time: 下午4:53
 */

namespace Common\Model;


class TypeAttrModel extends BaseModel
{
	protected $pk        = 'taid';
	protected $tableName = 'type_attr';


	/**
	 * @param $tid  类型id
	 * @param $gid  商品id
	 * @return 返回规格属性名及其属性值的数组
	 */
	public function getSpecList($tid,$gid){
		$specList = $this->where("tid=$tid and class=1")->select();
		foreach ($specList as $k=>$v){
			$specList[$k]['select'] = (new GoodsAttrModel())->where("taid={$v['taid']} and gid=$gid")->getField('gtid,gtid,gtvalue');
		}
		return $specList;
	}
}